package com.itboye.mengwu.main;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.core.object.BaseFragment;
import com.itboye.core.object.SpPublicParams;
import com.itboye.core.utils.SPUtils;
import com.itboye.mengwu.R;
import com.itboye.mengwu.app.login.ui.LoginActivity;
import com.itboye.mengwu.app.ui.aiwujia.ActivityAiwujiaMomPublish;
import com.itboye.mengwu.app.ui.aiwujia.ZengSongListFragment;
import com.itboye.mengwu.widget.AiZhiWuPagerSlidingTabStrip;

/**
 * author : shiqiyuan
 * 
 * hujiayi 2016年5月9日15:50:49
 * 
 */
public class MomZengFragement extends BaseFragment {

	ImageView search;
	TextView publish;
	int tag = 0;
	// View yuerjingLine;

	String[] titles = { "赠无限" };
	ViewPager pager;
	AiZhiWuPagerSlidingTabStrip tabs;
	ImageView txt_more;
	private String uid;

	@Override
	public int initView() {

		return R.layout.aiwujia_main;
	}

	@Override
	public void onMyActivityCreated() {

		pager.setAdapter(new MyAdapter(getChildFragmentManager(), titles));
		tabs.setViewPager(pager);
		uid = SPUtils.get(getContext(), null, SpPublicParams.UID, "") + "";
		publish.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				// if (tag == 0) {
				uid = SPUtils.get(getContext(), null, SpPublicParams.UID, "")
						+ "";
				Log.e("uid", uid);
				if ("".equals(uid) | uid == null) {
					Intent intent = new Intent(getActivity(),
							LoginActivity.class);
					startActivity(intent);
				} else {
					Intent intent = new Intent(getActivity(),
							ActivityAiwujiaMomPublish.class);
					startActivity(intent);
				}

			}
		});

	}

	public class MyAdapter extends FragmentStatePagerAdapter {
		String[] _titles;

		public MyAdapter(FragmentManager fm, String[] titles) {
			super(fm);
			_titles = titles;
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return _titles[position];
		}

		@Override
		public int getCount() {
			return _titles.length;
		}

		@Override
		public Fragment getItem(int position) {
			Fragment bfrag2 = null;
			if (position == 0) {
				bfrag2 = new ZengSongListFragment();
			}
			return bfrag2;
		}
	}
}
